const doSomeThing = new Promise((resolve) => {
    resolve('else')
})
const doOtherThing = new Promise((resolve) => {
    resolve('other')
})
doSomeThing.then(doOtherThing).then(data => console.log(data)) // else
doSomeThing.then(doOtherThing()).then(data => console.log(data))// error doOtherThing is not a function
doSomeThing.then(function () { return doOtherThing }).then(data => console.log(data))// other
doSomeThing.then(function () { doOtherThing }).then(data => console.log(data))// undefine




const flatten = (arr) => {
    const result = [];
    arr.forEach(item => {
        let tmp = item;
        if (Array.isArray(item)) {
            tmp = flatten(item)
            result.push(...tmp)
        } else {
            result.push(item)
        }
    });
    return result
}